package com.example.design.sercive;

import com.example.design.bridge.abst.AbstractRegisterLoginComponent;
import com.example.design.bridge.abst.RegisterLoginComponent;
import com.example.design.bridge.abst.factory.RegisterLoginComponentFactory;
import com.example.design.bridge.function.RegisterLoginByDefault;
import com.example.design.pojo.UserInfo;
import com.example.design.repo.UserRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Service
public class UserBridgeService {



    //用户登录
    public String login(String userName,String userPassword){
        AbstractRegisterLoginComponent component = RegisterLoginComponentFactory.getRegisterLoginComponent("Default");
        return component.login(userName,userPassword);
    }

    //用户注册
    public String register(UserInfo userInfo){
        //判断用户名是否已存在,账号名称需要唯一
        AbstractRegisterLoginComponent component = RegisterLoginComponentFactory.getRegisterLoginComponent("Default");
        return component.register(userInfo);
    }

    public String login3rd(HttpServletRequest request,String loginType){
        return RegisterLoginComponentFactory.getRegisterLoginComponent(loginType).login3rd(request);
    }
}
